package edu.tjut.cs.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import edu.tjut.cs.service.BuyService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
public class BuyController {
	@Autowired
	BuyService buyService;
	
	@ApiOperation(httpMethod="POST", notes="购买商品", value="第一个演示")
	@ApiImplicitParams({
		@ApiImplicitParam(name="customer_id", value="顾客ID", paramType="path", dataType="long"),
		@ApiImplicitParam(name="product_ids", value="不同商品ID构成的json数组，eg:[1,2,3]", paramType="body", dataType="String")
	})
	@PostMapping("/buy/{customer_id}")
	public String buy(@PathVariable("customer_id") long customer_id, @RequestBody Long[] product_ids) {
		buyService.buy(customer_id, product_ids);
		return "购买成功";
	}
}
